# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=tracker
pkgver=2.3.4
pkgrel=2
pkgdesc="Personal search tool and storage system"
url="https://wiki.gnome.org/Projects/Tracker"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	bash-completion
	dbus-dev
	glib-dev
	gobject-introspection-dev
	icu-dev
	json-glib-dev
	libsoup-dev
	libxml2-dev
	meson
	py3-setuptools
	sqlite-dev
	networkmanager-dev
	vala"
options="!check"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	lib$pkgname:libs
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-dbg"
source="https://download.gnome.org/sources/tracker/${pkgver%.*}/tracker-$pkgver.tar.xz"

build() {
	# https://gitlab.gnome.org/GNOME/tracker-miners/issues/91
	export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=2097152"

	meson \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--buildtype=plain \
		-Dsystemd_user_services=no \
		. output
	ninja -C output
}

check() {
	ninja -C output test
}

package() {
	DESTDIR="$pkgdir" ninja -C output install

	# Remove installed tests
	rm -r "$pkgdir"/usr/lib/tracker-2.0/trackertestutils
}

bashcomp() {
	pkgdesc="Bash completion for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	mkdir -p "$subpkgdir"/usr/share
	mv "$pkgdir"/usr/share/bash-completion "$subpkgdir"/usr/share
}

libs() {
	default_libs

	mkdir "$subpkgdir"/usr/lib/tracker-2.0
	mv "$pkgdir"/usr/lib/tracker-2.0/libtracker-data.so "$subpkgdir"/usr/lib/tracker-2.0
}

sha512sums="8b8ffc33962a5dffbae83dfb8ea73b0d2ff6ee002fbd9e4b574ef5f8e562338e359caab290ab804f2801a14e04d2c76eb0a52cf06be4d236ea043de4fc39dadf  tracker-2.3.4.tar.xz"
